from django import template
import os
import os.path
import settings
from django.http import HttpRequest
from mhlandscaping.apps.service.models import Category

register = template.Library()

@register.inclusion_tag('common/templates/navigation.html', takes_context=True)
def navigation(context, active = ''):

    return {
        'active': active,
        'settings': settings,
        }
    
@register.inclusion_tag('common/templates/breadcrumb.html', takes_context=True)
def breadcrumb(context, home = False, first='', second =''):
    
    print first
    
    return {
        'settings': settings,
        'home':home,
        'first':first,
        'second':second,
        }
    
@register.inclusion_tag('common/templates/title.html', takes_context=True)
def title(context, title):

    return {
        'title': title,
        }

@register.inclusion_tag('common/templates/form_errors.html', takes_context=True)
def form_errors(context,form):
        return {'form': form}

@register.inclusion_tag('common/templates/sitemap.html', takes_context=True)
def sitemap(context):
    try:
        categories = Category.objects.all().filter(active = True).order_by('name')
    except:
        pass
    return {'categories': categories,
             'settings': settings,
            }